package great.easychat.help.viewModel

import android.annotation.SuppressLint
import android.app.Application
import android.os.Bundle
import android.text.TextUtils
import androidx.lifecycle.MutableLiveData
import com.alibaba.fastjson.JSON
import com.google.gson.reflect.TypeToken
import com.pince.frame.mvvm.architecture.BaseViewModel
import com.pince.json.JsonUtil
import great.easychat.help.Constant
import great.easychat.help.bean.*
import great.easychat.help.http.HttpReposity

class CommonViewModel(application: Application, data: Bundle?) : AppBaseViewModel(application, data) {

    /**
     * 配置获取成功
     */
    val suggestLiveData: MutableLiveData<Boolean> by lazy { MutableLiveData<Boolean>() }


    @SuppressLint("CheckResult")
    public fun submitSuggest(suggestBean: SuggestBean) {
        getRepo(HttpReposity::class.java).addDataItem(Constant.XIAOBAI_APP_KEY, Constant.SUGGEST_DATA_NAME,  JSON.toJSONString(suggestBean))
                .subscribe({
                    var result = checkXiaobai(it)
                    if (result == 0) {
                        suggestLiveData.value = true
                    } else {
                        suggestLiveData.value = false
                    }
                }, {
                    suggestLiveData.value = false
                    it.printStackTrace()
                })
    }

}
